
#include "S_5_Alarm_doSet.h"
#include "mi_iid_define.h"
#include "spec.h"
#include "section1_set_func.h"
#include "main.h"

static void P_5_1_Alarm_doSet(property_operation_t *o)
{
    // 判断数据格式是否正确，如果错误，返回代码: OPERATION_ERROR_VALUE
    if (o->value.format != PROPERTY_FORMAT_BOOLEAN)
    {
        o->code = OPERATION_ERROR_VALUE;
        return;
    }

    // TODO: 执行写操作: o->value.data.boolean.value;

	LOG_INFO("%s, %d\r\n",__func__,o->value.data.boolean.value);
	
    // 如果成功，返回代码: OPERATION_OK
    o->code = OPERATION_OK;
    
    //上报状态，通知app状态变化，统一APP修改、定时器触发后的上报机制
//    P_5_1_Alarm_doChange_notify(o->value.data.boolean.value);
//		if(o->value.data.boolean.value == true)
//			SetAppAlarmFlag(SH_SET);
//		else
//			SetAppAlarmFlag(SH_RESET);		
		A02_5_1_Set(o->value.data.boolean.value);
		if(o->value.data.boolean.value == true)
		{
			SetAppAlarmFlag(SH_SET);
			g_BeepInvalidFlag = 0;
//			BeepStart();
		}
		else
		{
			SetAppAlarmFlag(SH_RESET);
			g_BeepInvalidFlag = 1;
		}
    return;
}

void S_5_Alarm_doSet(property_operation_t *o)
{
    switch (o->piid)
    {
        case PIID_5_1_Alarm:
            P_5_1_Alarm_doSet(o);
            break;

        default:
            o->code = OPERATION_ERROR_VALUE;
            break;
    }
}
